/*   
 * File    : tb_8b10b.v
 * Purpose : Test for 8b10b-code encoder and decoder
 * Author  : Golovchenko Aleksey
 * Date    : 2012/12/25
 */

`timescale 1ns / 1ns
module test_8b10b;

    reg [8:0] testin;
    reg dispin;    

    reg [9:0] decodein;
    reg decdispin;
   
    wire [9:0] 	testout;
    wire dispout, decodedisp, decodeerr, disperr;
    wire [8:0] 	decodeout;
    
    encode enc_inst(testin, dispin, testout, dispout);
    decode dec_inst(decodein, decdispin, decodeout, decodedisp, decodeerr, disperr);

    reg[8:0] i;

    // Генерирование последовательности входных данных
    initial begin
        $dumpfile("tb8b10b.vcd");
        $dumpvars(1, testin, dispin, dispout, testout);
        $dumpvars(1, decodein, decdispin, decodedisp, decodeout);
                
        decdispin = 0;
        dispin = 0;

        // Подаем на вход кодера целые числа          
        for (i=0; i<16; i=i+1) begin          
            testin = i;                  
            
            #1
            dispin = dispout;
        end            
    end 

    // Передача данных на декодер
    always @ (testin) begin        
        decodein = testout;
        decdispin = decodedisp;
    end
    
endmodule
